package com.sunlee.common.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sunlee.common.core.entity.BaseEntity;
import com.sunlee.common.service.dao.CommonUserDao;
import com.sunlee.common.service.dto.CommonUserDTO;
import com.sunlee.common.service.entity.CommonUserEntity;
import com.sunlee.common.service.service.CommonUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 用户
 *
 * @author sunlee
 * @since 2022-10-13
 */
@Service
public class CommonUserServiceImpl extends CrudServiceImpl<CommonUserDao, CommonUserEntity, CommonUserDTO> implements CommonUserService {

    @Override
    public LambdaQueryWrapper<CommonUserEntity> getWrapper(Map<String, Object> params) {
        String id = (String) params.get("id");
        String username = (String) params.get("username");

        LambdaQueryWrapper<CommonUserEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StringUtils.isNotBlank(id), CommonUserEntity::getId, id);
        wrapper.like(StringUtils.isNotBlank(username), CommonUserEntity::getUsername, username);

        return wrapper;
    }


}